<template>
  <div>
    <el-card class="box-card">
      <router-view/>
    </el-card>
  </div>
  
</template>

<script>
import {getorder,searchorder} from '../api/index'
  export default {
    data() {
      return {
        tableData: [],
        selected:"orderId",
        input:'',
        total:0,
        pageSize:5,
        pageNum:1
      }
    },
    async mounted(){
        let {data}=await getorder({pageNum:1,pageSize:5})
        this.tableData=data.data.list
        this.total=data.data.total
    },
    methods:{
      async getorder(val){
        let {data}=await getorder({pageNum:val,pageSize:5})
        this.tableData=data.data.list
      },
      async searchorder(type,val){
        let {data}=await searchorder({type:type,value:val,pageNum:this.pageNum,pageSize:5})
        this.tableData=data.data.list
        this.total=data.data.total
      },
      search(){
          this.searchorder(this.selected,this.input)
      },
      current_change(val){
          this.pageNum=val
          this.searchorder(this.selected,this.input)
      },
      handlenext(val) {
        this.pageNum=val
        this.searchorder(this.selected,this.input)
      },
      handleprev(val) {
        this.pageNum=val
        this.searchorder(this.selected,this.input)
      },
      goOrderDetail(id){
          this.$router.push(`/orderDetail/${id}`)
      },
      dateFormat: function (time) {
                var date = new Date(time);
                var year = date.getFullYear();
                /* 在日期格式中，月份是从0开始的，因此要加0
                 * 使用三元表达式在小于10的前面加0，以达到格式统一  如 09:11:05
                 * */
                var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
                var day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
                var hours = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
                var minutes = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
                var seconds = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
                // 拼接
                return year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds;
            },
    }

  }
</script>